﻿using System;
using NUnit.Framework;
using NumSkull;

namespace NumSkullTests
{
    [TestFixture]
    [Category("Usage")]
    public class HistogramUsage
    {
        [Test]
        public void ManuallyBinnedHistogram()
        {
            var histogram = new Histogram(new[] {1.12, 1.16, 1.20, 1.24, 1.28});

            histogram.Add(1.14);
            histogram.Add(1.15);
            histogram.Add(1.12);
            histogram.Add(1.15);
            histogram.Add(1.21);
            histogram.Add(1.25);

            foreach (var bin in histogram.Bins)
            {
                Console.Write(string.Format("Bin {0}-{1} contains: ", bin.Bounds.Lower, bin.Bounds.Upper));
                foreach (var value in bin.Values)
                {
                    Console.Write(string.Format("{0} ", value.Value));
                }
                Console.WriteLine();
            }
        }

        [Test]
        public void EvenlyBinnedHistogram()
        {
            var histogram = new Histogram(new Bounds(1.12, 1.28), 4);

            histogram.Add(1.14);
            histogram.Add(1.15);
            histogram.Add(1.12);
            histogram.Add(1.15);
            histogram.Add(1.21);
            histogram.Add(1.25);

            foreach (var bin in histogram.Bins)
            {
                Console.Write(string.Format("Bin {0}-{1} contains: ", bin.Bounds.Lower, bin.Bounds.Upper));
                foreach (var value in bin.Values)
                {
                    Console.Write(string.Format("{0} ", value.Value));
                }
                Console.WriteLine();
            }
        }
    }
}
